import { defineStore } from 'pinia'
import { HospitalDetail, Department } from '@/api/hospital/type'
// 引入获取详情的API
import { reqHospitalDetail, reqHospitalDepartment } from '@/api/hospital'

const useDetailStore = defineStore('detail', {
  state: () => {
    return {
      hospitalInfo: {} as HospitalDetail,
      department: [] as Department[]
    }
  },
  actions: {
    async getHospitalData(hoscode: string) {
      const { data } = await reqHospitalDetail(hoscode)
      this.hospitalInfo = data
    },
    async getDepartment(hoscode: string) {
      const { data } = await reqHospitalDepartment(hoscode)
      this.department = data
    }
  },
  getters: {}
})

export default useDetailStore
